<%@page import="java.text.SimpleDateFormat"%>
<%@page import="com.award.model.Commodity"%>
<%@page import="com.award.jdbc.dao.JdbcDao"%>
<%@ page language="java" import="java.util.*" contentType="text/html; charset=utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
if(null==session.getAttribute("manager")){
response.sendRedirect("./managerLogin.jsp");
}
JdbcDao jd=new JdbcDao();
List<Commodity> commodity_list=jd.queryAllCommodity();
List<Commodity> commodity_join=new ArrayList<Commodity>();
for(Commodity c:commodity_list){
if(1==c.getAward()){
commodity_join.add(c);
}
}
SimpleDateFormat bartDateFormat = new SimpleDateFormat(
				"yyyy-MM-dd HH:mm");
int i=1;
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'commodityDone.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
	<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
    <link rel="stylesheet" href="./css/font.css">
    <link rel="stylesheet" href="./css/xadmin.css">
    <script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
    <script type="text/javascript" src="./lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="./js/xadmin.js"></script>

  </head>
  
  <body>
    <div class="x-nav">
      <span class="layui-breadcrumb">
       
      </span>
      <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新">
        <i class="layui-icon" style="line-height:30px">ဂ</i></a>
    </div>
    <div class="x-body">
     
      <xblock>
        <button class="layui-btn layui-btn-danger" ></button>
        <span class="x-right" style="line-height:40px">共有数据：<%= commodity_list.size() %> 条</span>
      </xblock>
      <table class="layui-table">
        <thead>
          <tr>
            <th>次序</th>
            <th>名称</th>
            <th>价格</th>
            <th>开奖时间</th>
            <th>状态</th>
            <th>操作</th></tr>
        </thead>
        <tbody>
        <% for(Commodity c:commodity_join) {%>
          <tr>
            <td><%= i++ %></td>
            <td><%= c.getCommodityName()  %></td>
            <td><%= c.getPrice() %></td>
            <td><%= bartDateFormat.format(c.getOpenTime()) %></td>
            <td class="td-status">
            <% if(1==c.getAward()){ %>
              <span class="layui-btn layui-btn-normal layui-btn-mini">已开奖</span></td>
              <%}else if(0==c.getAward()){ %>
              <span class="layui-btn layui-btn-normal layui-btn-mini">未开奖</span></td>
              <%}else if(-1==c.getAward()){ %>
              <span class="layui-btn layui-btn-normal layui-btn-mini">等待....</span></td>
              <%} %>
            <td class="td-manage">
              <a title="删除" href="">
                <i class="layui-icon">&#xe640;</i>
              </a>
            </td>
          </tr>
          <%} %>
        </tbody>
      </table>
      <div class="page">
        <div>
          <a class="prev" href="">&lt;&lt;</a>
          <a class="num" href="">1</a>
          <a class="next" href="">&gt;&gt;</a>
        </div>
      </div>

    </div>
  </body>
</html>
